package com.block.source.factory;

import com.block.common.util.ApplicationContextUtil;
import com.block.datapush.service.apipush.XinYongPaiPushApiService;
import com.block.source.enums.ReceiveTypeEnum;
import com.block.source.service.ISourceCallBackService;
import com.block.source.service.ISourceReceiveService;
import com.block.source.service.receive.*;

import java.util.HashMap;
import java.util.Map;

public class SourceApiFactory {

    private static final Map<String, Class<? extends ISourceReceiveService>> serviceMap = new HashMap<>();
    private static final Map<String, Class<? extends ISourceCallBackService>> callBackServiceMap = new HashMap<>();
    static {
        serviceMap.put(ReceiveTypeEnum.DEFAULT.getValue(), DefaultReceiveService.class);
        serviceMap.put(ReceiveTypeEnum.HONGHUAJIEKUAN.getValue(), HongHuaJieKuanReceiveService.class);
        serviceMap.put(ReceiveTypeEnum.PAIYIDAI.getValue(), PaiYiDaiReceiveService.class);
        serviceMap.put(ReceiveTypeEnum.XINXIAORONG.getValue(), XinXiaoRongReceiveService.class);
        serviceMap.put(ReceiveTypeEnum.JIQIONGBAO.getValue(), JiQiongBaoReceiveService.class);
        serviceMap.put(ReceiveTypeEnum.JUYOUHUA.getValue(), JuYouHuaReceiveService.class);
        serviceMap.put(ReceiveTypeEnum.CAIMIYOUJIN.getValue(), CaiMiYouJinReceiveService.class);
        serviceMap.put(ReceiveTypeEnum.COMMON.getValue(), CommonReceiveService.class);
        serviceMap.put(ReceiveTypeEnum.TONGCHENGJIE.getValue(), TongChengJieReceiveService.class);
        serviceMap.put(ReceiveTypeEnum.XIAOANQIANBAO.getValue(), XiaoAnQianBaoReceiveService.class);
        serviceMap.put(ReceiveTypeEnum.RENYIHUA.getValue(), RenYiHuaReceiveService.class);
        serviceMap.put(ReceiveTypeEnum.XIAOMEIYIRONG.getValue(), XiaoMeiYiRongReceiveService.class);
        serviceMap.put(ReceiveTypeEnum.WUYIWEIQIANBAO.getValue(), WuYiWeiQianBaoReceiveService.class);
        serviceMap.put(ReceiveTypeEnum.LIANZONGQIANBAO.getValue(), LianZongQianBaoReceiveService.class);
        serviceMap.put(ReceiveTypeEnum.XINYONGPAI.getValue(), XinYongPaiReceiveService.class);
        serviceMap.put(ReceiveTypeEnum.YIRONGGUANGGAO.getValue(), YiRongGuangGaoReceiveService.class);
        serviceMap.put(ReceiveTypeEnum.WEIHAOYONG.getValue(), WeiHaoYongReceiveService.class);
        serviceMap.put(ReceiveTypeEnum.CHENGYIRONG.getValue(), ChengYiRongReceiveService.class);
        serviceMap.put(ReceiveTypeEnum.CHUANBEIFENQIRATE.getValue(), ChuanBeiFenQiReceiveService.class);
        serviceMap.put(ReceiveTypeEnum.JINYAODAIRATE.getValue(), JinYaoDaiReceiveService.class);
        serviceMap.put(ReceiveTypeEnum.HUARONGFENQIRATE.getValue(), HuaRongFenQiReceiveService.class);
        serviceMap.put(ReceiveTypeEnum.COMMONMASK.getValue(), CommonMaskReceiveService.class);
        serviceMap.put(ReceiveTypeEnum.KAIXINHUAMASK.getValue(), KaiXinHuaReceiveService.class);
        serviceMap.put(ReceiveTypeEnum.JIAHUITONGMASK.getValue(), JiaHuiTongReceiveService.class);


        callBackServiceMap.put(ReceiveTypeEnum.WUYIWEIQIANBAO.getValue(), WuYiWeiQianBaoReceiveService.class);


    }

    public static ISourceReceiveService getService(String pushType){
        if (serviceMap.containsKey(pushType)){
            Class<? extends ISourceReceiveService> aClass = serviceMap.get(pushType);
            return ApplicationContextUtil.getBean(aClass);
        }
        return null;
    }
    public static ISourceCallBackService getCallBackService(String pushType){
        if (serviceMap.containsKey(pushType)){
            Class<? extends ISourceCallBackService> aClass = callBackServiceMap.get(pushType);
            return ApplicationContextUtil.getBean(aClass);
        }
        return null;
    }
}
